import { createRouter, createWebHashHistory } from 'vue-router'
import { getRouter } from '../components/js/utile.js'

import menuList from './routes.js'

// console.log(menuList)
const router = createRouter({
  history: createWebHashHistory(), // hash 模式
  routes: getRouter(menuList),
})

router.beforeEach((to, from, next) => {
  // console.log('路由前置守卫')
  // console.log(to, from)
  if (to.fullPath === '/') {
    next('/home/')
  } else {
    next()
  }
})
router.afterEach((to, from) => {
  // console.log('路由后置守卫')
  // console.log(to, from)
})
export default router
